<%--
  Created by IntelliJ IDEA.
  User: ShiYan.Shi
  Date: 2018/11/14        
  Time: 0:04
  To change this template use File | Settings | File Templates.
  包埋管理界面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/taglibs.jspf" %>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="sys.user.title"/></title>
    <meta name="decorator" content="list"/>
    <link rel="stylesheet" href="${staticPath}/css/font-awesome.min.css">
    <style>
        #middleContent .infoTable td {
            text-align: left;
            position: relative;
            padding: 1px 0px;
            min-height: 20px;
            line-height: 20px;
            /*font-size: 12px;*/
            font-weight: bold;
        }

        #middleContent .infoTable td input {
            width: 100px;
        }
    </style>
</head>
<body title="<spring:message code="sys.user.title" />">
<%--左侧病理取材信息列表  md3 25%--%>
<div id="leftContent" class="layui-col-md5" style="width: 40%" >
    <div class="layui-tab layui-tab-card" lay-filter="listTab">
        <ul class="layui-tab-title">
            <%--默认选项卡--%>
            <li class="layui-this">未包埋</li>
            <li>已包埋</li>
        </ul>

    </div>
    <%-- <div class="layui-form-item">
         <div class="layui-inline">
             <label class="layui-form-label">取材日期:</label>
             <div class="layui-input-inline" style="width: 80px;">
                 <input id="startPieSamplingTime" type="text" placeholder="" style="width: 80px;height: 25px;"class="layui-input">
             </div>
             <div class="layui-form-mid">-</div>
             <div class="layui-input-inline" style="width: 80px;">
                 <input id="endPieSamplelingTime" type="text" placeholder="" style="width: 80px;height: 25px;" class="layui-input">
             </div>
         </div>
     </div>
     <div class="layui-form-item">
         <div class="layui-col-md6">
             <label class="layui-form-label">患者姓名:</label>
             <div class="layui-input-block">
                 <input id="samPatientName" type="text" name="title" lay-verify="title"  style="width: 100px;height: 25px;"  autocomplete="off" placeholder="请输入患者姓名"
                        class="layui-input">
             </div>
         </div>
     </div>
     <div class="layui-form-item">
         <div class="layui-col-md6">
             <label class="layui-form-label">门诊住院号:</label>
             <div class="layui-input-block">
                 <input id="samPatientNumber" type="text" name="title"  style="width: 150px;height: 25px;"  lay-verify="title" autocomplete="off" placeholder="请扫描门诊&住院号"
                        class="layui-input">
             </div>
         </div>
     </div>
     <div class="layui-form-item">
         <div class="layui-col-md6">
             <label class="layui-form-label">取材医生:</label>
             <div class="layui-input-block">
                 <input id="pieDoctorName" type="text" name="title" lay-verify="title"  style="width: 80px;height: 25px;"  autocomplete="off" placeholder="请输入"
                        class="layui-input">
             </div>
         </div>
     </div>
     <div class="layui-form-item">
         <div class="layui-inline">
             <label class="layui-form-label">病理编号:</label>
             <div class="layui-input-inline" style="width: 80px;">
                 <input id="startPiePathologyCode" type="text" placeholder=""  style="width: 80px;height: 25px;"  class="layui-input">
             </div>
             <div class="layui-form-mid">-</div>
             <div class="layui-input-inline" style="width: 80px;">
                 <input id="endPiePathologyCode" type="text" placeholder=""  style="width: 80px;height: 25px;"  class="layui-input">
             </div>
         </div>
     </div>
     <div class="layui-col-md6">
         <label class="layui-form-label">匹配区分:</label>
         <div class="layui-input-block">
             <select name="matchingDistinctionSelect" lay-filter="matchingDistinctionSelect"
                     id="matchingDistinctionSelect">
                 <option value="">全部</option>
                 <c:forEach var="item" items="${matchingDistinctionList}">
                     <option value="${item.code}">${item.name}</option>
                 </c:forEach>
             </select>
         </div>
     </div>--%>
    <%--  <div class="layui-form-item">
          <div class="layui-input-block">
              <button id="leftQueryButton" class="layui-btn layui-btn-md" onclick="leftQuery();">查询</button>
              <button id="leftResetButton" class="layui-btn layui-btn-primary layui-btn-md" onclick="leftReset();">重置</button>
          </div>
      </div>--%>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show" id="patientListTab">
            <div class="site-title">
                <div class="layui-col-md12 rightTop" id="hasCrossTop">
                    <div class="layui-form" id="sampleForm">
                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label">登记日期:</label>
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input id="startRegistrationDate" type="text" placeholder="" class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input id="endRegistrationDate" type="text" placeholder="" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <label class="layui-form-label">患者姓名:</label>
                                <div class="layui-input-block">
                                    <input id="patientName" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label">病理编号:</label>
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input id="startPathologyCode" type="text" name="price_min" placeholder="" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline" style="width: 100px;">
                                    <input id="endPathologyCode" type="text" name="price_max" placeholder="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <label class="layui-form-label">门诊住院号:</label>
                                <div class="layui-input-block">
                                    <input id="patientServiceNum" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-col-md6">
                                <label class="layui-form-label">在院区分:</label>
                                <div class="layui-input-block" style="width: 60%;margin-left: 90px;">
                                    <select name="matchingDistinctionSelect" lay-filter="matchingDistinctionSelect" id="matchingDistinctionSelect">
                                        <option value="">全部</option>
                                        <c:forEach var="item" items="${matchingDistinctionList}">
                                            <option value="${item.code}">${item.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <label class="layui-form-label">取材医生:</label>
                                <div class="layui-input-block">
                                    <input id="doctorName" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </div>


                        <div class="layui-form-item">
                            <div class="layui-col-md6" style="margin-top: 10px;">
                                <label class="layui-form-label" ></label>
                                <button id="leftQueryButton" class="layui-btn layui-btn-sm" onclick="leftQuery();">查询</button>
                                <button id="leftResetButton" class="layui-btn layui-btn-primary layui-btn-sm" onclick="leftReset();">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <grid:grid id="patientList" rowNum="100" onSelectRow="patientListSelected" multiboxonly="false"
                       url="${appPath}/technician/embed/dataQuery" queryGroup="2" height="300">
                <%--列表显示--%>
                <grid:column label="病理编号" name="piePathologyCode" /><%--病理编号--%>
                <grid:column label="patient.inhos.name" name="samPatientName" /><%--患者姓名--%>
                <grid:column label="sys.patient.number" name="samPatientNumber" /><%--住院门诊号--%>
                <grid:column label="材块编号" name="pieCode"/><%--材块编号--%>
                <grid:column label="取材部位" name="pieParts"/><%--取材部位--%>
                <grid:column label="取材医生姓名" name="pieDoctorName" /><%--取材医生姓名--%>
                <grid:column label="取材日期" name="pieSamplingTime" /><%--取材日期--%>
                <%--隐藏--%>
                <grid:column label="材块id" name="id" hidden="true"/><%--材块id--%>
                <grid:column label="标本id" name="pieSampleId" hidden="true"/><%--标本id--%>
                <grid:column label="取材序号" name="pieSamplingNo" /><%--取材序号--%>
                <grid:column label="sample.record.date" name="pieState" hidden="true"/><%--状态(0保存1取材2包埋)--%>
                <grid:column label="sample.record.date" name="pieIsDeprivation" hidden="true"/><%--是否脱水--%>
                <grid:column label="sample.record.date" name="pieDeprivationTime" hidden="true"/><%--脱水时间--%>
                <%--<grid:toolbar function="search"/>--%>
                <%--<grid:toolbar  function="showCol" layout="right" title="列定制" url="${appPath}/system/common/showcol" />--%>
            </grid:grid>
        </div>
    </div>
</div>

<%--右边包埋操作页面  md6 --%>
<div id="middleContent" class="layui-col-md7">
    <div class="layui-tab layui-tab-card" lay-filter="listTab">
        <div class="layui-card-header">
            <label class="control-label no-padding-right">常用功能</label>
            <span class="btn-group" style="float: right"/>
            <div class="layui-col-md12 layui-fluid">
                <div class="layui-form">
                    <div class="layui-form-item" style="margin-bottom: 0px !important;">
                        <div class="layui-input-inline" style="width: 48px !important;">
                            <div class="layui-input-inline" style="margin-right: 158px !important;">
                                <button class="layui-btn layui-btn-sm btn-xs"
                                        onclick="entry.sendNotice()">包埋
                                </button>
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 68px !important;">
                            <div class="layui-input-inline" style="margin-right: 158px !important;">
                                <button class="layui-btn layui-btn-sm layui-btn-info btn-xs"
                                        onclick="entry.printReport()">取消包埋
                                </button>
                            </div>
                        </div>
                        <div class="layui-input-inline" style="width: 68px !important;">
                            <div class="layui-input-inline" style="margin-right: 158px !important;">
                                <button class="layui-btn layui-btn-sm layui-btn-success btn-xs"
                                        onclick="entry.printReport()">包埋列表打印
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-tab layui-tab-card" lay-filter="listTab">
        <div class="layui-card-header">
            <label class="control-label no-padding-right">患者申请信息</label>
            <span class="btn-group" style="float: right"/>
        </div>
        <div class="layui-fluid">
            <div id="patientInfo">
                <form:form modelAttribute="apply" method="post" class="layui-form"
                           lay-filter="component-form-group">
                    <table class="infoTable" style="width: 100%">
                        <colgroup>
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col width="10%">
                            <col>
                        </colgroup>
                        <tbody>
                        <tr>
                            <td>病理编号&emsp;：</td>
                            <td><input type="text" id="samPathologyCode" class="patientInfo" disabled="disabled"
                                       readonly="true" style="width: 100px"/></td>
                            <td>送检医生&emsp;：</td>
                            <td><input type="text" id="samReqDocCode" class="patientInfo" disabled="disabled" readonly="true"
                                       style="width: 100px"/></td>
                            <td>送检单位：</td>
                            <td><input type="text" id="samSendHospitalName" class="patientInfo" disabled="disabled"
                                       readonly="true" style="width: 100px"/></td>
                            <td>送检科室&emsp;：</td>
                            <td><input type="text" id="samSendDeptName" class="patientInfo" disabled="disabled" readonly="true"
                                       style="width: 100px"/></td>
                        </tr>
                        <tr>
                            <td>门诊住院号：</td>
                            <td><input type="text" id="samPatientNumber" class="patientInfo" disabled="disabled"
                                       readonly="true"/></td>
                            <td>患者姓名&emsp;：</td>
                            <td><input type="text" id="samPatientName" class="patientInfo" disabled="disabled"
                                       readonly="true"/></td>
                            <td>床位号&emsp;&emsp;：</td>
                            <td><input type="text" id="samPatientBed" class="patientInfo" disabled="disabled" readonly="true">
                            </td>
                            <td>年&emsp;&emsp;&emsp;龄：</td>
                            <td><input type="text" id="samPatientAge" class="patientInfo" disabled="disabled" readonly="true">
                            </td>

                        </tr>
                        <tr>
                            <td>送检材料&emsp;：</td>
                            <td colspan="3"><input type="text" id="samSampleName" class="patientInfo double-size"
                                                   disabled="disabled" readonly="true" style="width: 96.5%"/></td>
                            <td>临床诊断&emsp;：</td>
                            <td colspan="3"><input type="text" id="samDignoses" class="patientInfo double-size"
                                                   disabled="disabled" readonly="true" style="width: 96.5%"/></td>
                        </tr>
                        <tr>
                            <td>手术所见&emsp;：</td>
                            <td colspan="3"><input type="text" id="samOpsShow" class="patientInfo double-size"
                                                   disabled="disabled" readonly="true" style="width: 96.5%"/></td>
                            <td>性&emsp;&emsp;&emsp;别 ：</td>
                            <td><input type="text" id="samPatientSex" class="patientInfo" disabled="disabled" readonly="true">
                            </td>


                        </tr>
                        </tbody>
                    </table>
                </form:form>
            </div>
        </div>
    </div>
    <div class="layui-tab layui-tab-card" lay-filter="listTab">
        <div class="layui-card-header">
            <label class="control-label no-padding-right">包埋材块列表</label>
            <span class="btn-group" style="float: right"/>
        </div>

        <%--<div class="layui-tab-content">--%>
            <%--<div class="layui-tab-item layui-show" id="embedListTab">--%>
                <%--<grid:grid id="patientList" rowNum="100" onSelectRow="patientListSelected" multiboxonly="false"--%>
                <%--url="${appPath}/technician/embed/getEmbedBlockList" queryGroup="1" height="300">--%>
                <%--<grid:column label="材块编号" name="pieCode" readonly="true" text="3232"/>&lt;%&ndash;材块编号&ndash;%&gt;--%>
                <%--<grid:column label="材块号" name="id" readonly="true"/>&lt;%&ndash;材块号&ndash;%&gt;--%>
                <%--<grid:column label="白片" name="parnullSlideNum" readonly="true"/>&lt;%&ndash;白片&ndash;%&gt;--%>
                <%--<grid:column label="取材部位" name="pieParts" readonly="true"/>&lt;%&ndash;取材部位&ndash;%&gt;--%>
                <%--<grid:column label="特殊要求" name="pieSpecial" readonly="true"/>&lt;%&ndash;特殊要求&ndash;%&gt;--%>
                <%--<grid:column label="取材医生" name="pieDoctorName" readonly="true"/>&lt;%&ndash;取材医生&ndash;%&gt;--%>
                <%--<grid:column label="取材时间" name="pieSamplingTime" readonly="true"/>&lt;%&ndash;取材时间&ndash;%&gt;--%>
                <%--<grid:column label="包埋医生" name="pieEmbedDoctorName" readonly="true"/>&lt;%&ndash;包埋医生&ndash;%&gt;--%>
                <%--<grid:column label="包埋时间" name="pieEmbedTime" readonly="true"/>&lt;%&ndash;包埋时间&ndash;%&gt;--%>
                <%--</grid:grid>--%>

            <%--</div>--%>
        <%--</div>--%>
    </div>
    <div class="widget-main no-padding" Class="layui-col-md7">
        <table id="new1" class="table-striped">
        </table>
    </div>
</div>


<script>
    var lastApplyId
    var lastPatientId
    var windowsHeight = document.documentElement.clientHeight; //页面高度
    var bigWidth
    var bigHeight
    var shortWidth
    var shortHeight
    var detailSwitch = true;
    var changeCount = 0;
    layui.use(['layer', 'form','element','laydate'], function(){
        var layer = layui.layer,
            form = layui.form,
            element = layui.element,
            laydate = layui.laydate;


        //初始化laydate
        initRegistrationDate(laydate);

        var _startDate =laydate.render({
            elem: '#startMatchingDate',
            btns: ['clear', 'confirm'],//设置底部按钮
            value:getDateStr(-7),//设置默认值为七天前日期
            max:0,//设置最大值为当前日期
            done: function (value, date) { //开始日期改变时设置结束日期的最小值
                if (value !== '') {
                    _endDate.config.min.year = date.year;
                    _endDate.config.min.month = date.month - 1;
                    _endDate.config.min.date = date.date;
                } else {
                    _endDate.config.min.year = '';
                    _endDate.config.min.month = '';
                    _endDate.config.min.date = '';
                }
            }
        });
        var _endDate =laydate.render({
            elem: '#endMatchingDate',
            btns: ['clear', 'confirm'],//设置底部按钮
            value: new Date(),//设置默认值为当前日期
            max: 0,//设置最大值为当前日期
            done: function (value, date) {//结束日期改变时设置开始日期的最大值
                if (value !== '') {
                    _startDate.config.max.year = date.year;
                    _startDate.config.max.month = date.month - 1;
                    _startDate.config.max.date = date.date;
                } else {
                    _startDate.config.max.year = '';
                    _startDate.config.max.month = '';
                    _startDate.config.max.date = '';
                }
            }
        });

        //select change事件
        /*form.on('select(matchingDistinctionSelect)', function(data){
            getSampleList();
        });*/

    });

    //初始化登记时间控件
    function initRegistrationDate (laydate){
        var startDate  = laydate.render({
            elem: '#startRegistrationDate',
            btns: ['clear', 'confirm'],//设置底部按钮
            value:getDateStr(-7),//设置默认值为七天前日期
            max:0,//设置最大值为当前日期
            done: function (value, date) { //开始日期改变时设置结束日期的最小值
                if (value !== '') {
                    endDate.config.min.year = date.year;
                    endDate.config.min.month = date.month - 1;
                    endDate.config.min.date = date.date;
                } else {
                    endDate.config.min.year = '';
                    endDate.config.min.month = '';
                    endDate.config.min.date = '';
                }
            }
        });
        var endDate  =laydate.render({
            elem: '#endRegistrationDate',
            btns: ['clear', 'confirm'],//设置底部按钮
            value: new Date(),//设置默认值为当前日期
            max: 0,//设置最大值为当前日期
            done: function (value, date) {//结束日期改变时设置开始日期的最大值
                if (value !== '') {
                    startDate.config.max.year = date.year;
                    startDate.config.max.month = date.month - 1;
                    startDate.config.max.date = date.date;
                } else {
                    startDate.config.max.year = '';
                    startDate.config.max.month = '';
                    startDate.config.max.date = '';
                }
            }
        });
    }
    /*
    * layui form样式初始化
    * */
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        form.on('select(bloodDeptSelect)', function (data) {
            $("#bloodDeptEvaluation").val($("#bloodDeptEvaluation").val() + "，" + data.value)
            form.render();
        });

        //监听指定开关
        form.on('switch(showDetail)', function (data) {
            if (this.checked) {
                showDetailSize()
                detailSwitch = true;
                $("input[name='close']").prop('checked', 'checked');  //改变开关为 开
                form.render('checkbox')
            } else {
                hideDetailSize()
                detailSwitch = false;
                $("input[name='close']").removeAttr('checked');  //改变开关为 关
                form.render('checkbox')
            }
        });


    })

    /*
    * tab切换相应事件
    * */
    layui.use('element', function () {
        var $ = layui.jquery,
            form = layui.form
        element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        //申请详细信息tab切换监听
        element.on('tab(listTab)', function (data) {
            switch (data.index) {
                case 0:
                    showDetailSize()
                    detailSwitch = true;
                    $("input[name='close']").prop('checked', 'checked');  //改变开关为 开
                    form.render('checkbox')
                    break;
                default:
                    break
            }

        });
        //申请详细信息tab切换监听
        element.on('tab(detailTab)', function (data) {
            switch (data.index) {
                case 0:
                    getBloodDetailTab()
                    break;
                case 1:
                    getTransfusionTab()
                    break;
                case 2:
                    getFeedbackTab()
                    break;
                case 3:
                    getAfterEvaluation()
                    break;
                default:
                    break
            }

        });
    });

    $(function () {
        /*
        *载入页面各个表格宽度和高度修正
         */
        var leftHeight = windowsHeight - $("#applyListGridQuery").height() - 170;
        var leftWidth = $("#gbox_applyListGrid").width();
        $("#applyListGrid").setGridHeight(leftHeight);
        shortWidth = leftWidth;
        shortHeight = leftHeight;
        var rightWidth = $("#rightContent").width();

        $("#leftContent #applyListTab .pull-left").append("" +
            "<form class='layui-form' style='display: inline !important;'>" +
            "<div class='layui-form-item' style='display: inline !important;'>" +
            "<div class='layui-input-inline' style='float: none !important;width: 60px'> " +
            "<input type='checkbox' checked='' class='detailSwitch' id='showDetail' name='close' lay-skin='switch' lay-filter='showDetail' lay-text='详情|隐藏'> </div> " +
            "</div></form>");

        var clientHeight=$("html").innerHeight();
        var height =clientHeight- $("#div_1").height()-50-$("#head").height() - 210-56;
        $("#new1").jqGrid({
            // url:"../pathologysample/pieces/ajax/getItem",
            datatype: "json",
            mtype:"GET",
            height:height,
            // width:width1,
            // postData:{"reqId":reqid},
            colNames: ['样本ID','材块ID','蜡块ID','病理编号','蜡块名称','蜡块序号','蜡块标签','蜡块条码号','材块编号','材块数','白片数', '取材部位',
                '是否已切片','切片医生','切片时间','是否已打印标签','标签打印人员','标签打印时间','剩余处理','特殊要求', '取材时间','取材技术员',
                '包埋时间','包埋医生ID','包埋技术员', '包埋状态','材块ID'],
            colModel: [
                {name:'parsampleid',hidden:true},//样本ID
                {name:'parpieceids',hidden:true},//材块ID
                {name:'paraffinid',hidden:true},//蜡块ID
                {name:'parpathologycode',hidden:true},//病理编号
                {name:'parname',hidden:true},//蜡块名称
                {name:'parparaffinno',hidden:true},//蜡块序号
                {name:'parparaffincode',hidden:true},//蜡块标签
                {name:'parbarcode',hidden:true},//蜡块条码号
                { name: 'piecode', index: 'piecode',width:"120px",align:"center"},//材块编号
                { name: 'parpiececount', index: 'parpiececount',width:"60px",align:"center"},//材块数
                { name: 'parnullslidenum', index: 'parnullslidenum',width:"60px",align:"center"},//白片数
                { name: 'parpieceparts', index: 'parpieceparts',width:"100px",align:"center"},//取材部位
                {name:'parissectioned',hidden:true},//是否已切片
                {name:'parsectioneddoctor',hidden:true},//切片医生
                {name:'parsectionedtime',hidden:true},//切片时间
                {name:'parisprintlabel',hidden:true},//是否已打印标签
                {name:'parprintuser',hidden:true},//标签打印人员
                {name:'parprinttime',hidden:true},//标签打印时间
                {name:'parremaining',hidden:true},//剩余处理
                { name: 'piespecial', index: 'piespecial',width:"100px",align:"center"},//特殊要求
                { name: 'piesamplingtime', index: 'piesamplingtime',width:"100px",align:"center",
                    formatter:function(cellvalue, options, row){if(cellvalue==null || cellvalue == ""){return ""}return CurentTime(new Date(cellvalue))},width:"100px",align:"center"},//取材时间
                { name: 'piedoctorname', index: 'piedoctorname',width:"80px",align:"center"},//取材医生
                { name: 'pieembedtime', index: 'pieembedtime',
                    formatter:function(cellvalue, options, row){if(cellvalue==null || cellvalue == ""){return ""}return CurentTime(new Date(cellvalue))},width:"100px",align:"center"},//包埋时间
                {name:'pieembeddoctorid',hidden:true},//包埋医生ID
                { name: 'pieembeddoctorname', index: 'pieembeddoctorname',width:"80px",align:"center"},//包埋医生
                { name: 'pieisembed', index: 'pieisembed',formatter: "select", editoptions:{value:"0:未包埋;1:已包埋"},width:"80px",align:"center"},//包埋状态
                {name:'pieceid',hidden:true}//材块ID
            ],
            loadComplete : function() {
                var table = this;
                setTimeout(function(){
                    updatePagerIcons(table);
                }, 0);
            },
            beforeEditCell:function(rowid,cellname,v,iRow,iCol){
                canChange(rowid,1);
            },
            shrinkToFit:false,
            viewrecords: true,
            rownumbers : true,
            ondblClickRow: function (id) {
                var rowData = $("#new1").jqGrid('getRowData',id);
                $('#sampleForm')[0].reset();
                getSampleData(rowData.parsampleid);
            },
            onSelectRow:function(id,status){
                var rowData = $("#new1").jqGrid('getRowData',id);
                $('#sampleForm')[0].reset();
                getSampleData(rowData.parsampleid);
            },
            onSelectAll:function(aRowids,status){
                var rowIds = $("#new1").jqGrid('getDataIDs');
                for(var k = 0; k<rowIds.length; k++) {
                    var curRowData = jQuery("#new1").jqGrid('getRowData', rowIds[k]);
                    var curChk = $("#"+rowIds[k]+"").find(":checkbox");
                    if(status){
                        curChk.attr('checked', 'true');   //设置所有checkbox被选中
                    }else{
                        curChk.attr('checked', 'false');   //设置所有checkbox被选中
                    }
                }
            }
        });

    });

    function leftQuery(){
        //获取数据
        var data ={};
        data.startPieSamplingTime = $("#startRegistrationDate").val();
        data.endPieSamplingTime = $("#endRegistrationDate").val();
        data.samPatientName = $("#patientName").val();
        data.samPatientNumber = $("#patientServiceNum").val();
        data.pieDoctorName = $("#doctorName").val();
        data.startPiePathologyCode = $("#startPathologyCode").val();
        data.endPiePathologyCode = $("#endPathologyCode").val();

        //异步请求更新grid
        $.ajax({
            type: "get",
            dataType: "json",
            contentType:"application/json;charset=utf-8",
            data: data,
            url: baseUrl + "/technician/embed/dataQuery",
            success: function (a) {
                // 清空数据
                $("#pathologyPeicesListGrid").jqGrid("clearGridData");
                //设定数据
                $("#pathologyPeicesListGrid")[0].addJSONData(a);
            }
        })
    }

    function getDateStr(AddDayCount) {
        var dd = new Date();
        dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
        var y = dd.getFullYear();
        var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期，不足10补0
        var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();//获取当前几号，不足10补0
        return y+"-"+m+"-"+d;
    }


    function leftReset(){
        $("#matchingDistinctionSelect").val("");
        $("#patientName").val("");
        $("#startPathologyCode").val("");
        $("#endPathologyCode").val("");
        initRegistrationDate(layui.laydate);
        layui.form.render();
    }

    /*
    病人列表选中事件
    */
    function patientListSelected(rowid, iRow, iCol, e) {
        var patientIds = $("#patientListGrid").jqGrid("getGridParam", "selarrrow");
        leftListSelected(patientIds, "");

    }

    /*
    申请列表选中事件
    */
    function applyListSelected(rowid, iRow, iCol, e) {
        var applyIds = $("#applyListGrid").jqGrid("getGridParam", "selarrrow");
        leftListSelected('', applyIds);

    }

    /*
    申请记录表选中事件
    */
    function applyRecordListSelected(rowid, iRow, iCol, e) {
        var rowData = $("#applyRecordListGrid").jqGrid('getRowData', rowid);
        lastApplyId = rowData.applyId;
        lastPatientId = rowData.patientId;
        $("#applyDetailListGrid").clearGridData()
        getPatientInfo()
        if (rowData.isPrint == 1) {
            getVersionNo(lastApplyId)
        }
        if ($("#bloodDetailTab").hasClass("layui-show")) {
            getBloodDetailTab(rowData.bloodReason)
        }
        if ($("#bloodInfusionTab").hasClass("layui-show")) {
            getTransfusionTab()
        }
        if ($("#feedBackTab").hasClass("layui-show")) {
            getFeedbackTab()
        }

        if ($("#afterEvaluationTab").hasClass("layui-show")) {
            getAfterEvaluation()
        }

    }

    /**
     * 获取病人信息
     */
    function getPatientInfo() {
        var versionNo = $("#versionNo").val() || ''
        //获取病人信息
        $.ajax({
            type: "GET",
            dataType: "json",
            data: {
                applyId: lastApplyId,
                patientId: lastPatientId,
                versionNo: versionNo
            },
            url: baseUrl + "/apply/normal/getPatientInfo",
            success: function (data) {
                if (data.patient != undefined) {
                    setValue("table .patientInfo", data.patient)
                }
            }
        })
    }
    /*
        左侧列表选中事件 获取病人申请 或者获取申请其他详细信息
         */
    function leftListSelected(patientIds, applyIds) {
        if (!detailSwitch) {
            return clearData()
        }
        if (patientIds.length < 1 && applyIds.length < 1) {
            return clearData()
        }
        clearData()

        //获取该病人或者该申请详细申请记录
        $('#applyRecordListGrid').jqGrid('setGridParam', {
            url: baseUrl + "/apply/normal/getApplyRecordList",
            datatype: 'json',
            //发送数据
            postData: {
                patientIds: patientIds.toString(),
                applyIds: applyIds.toString()
            },
            page: 1,
            loadComplete: function () {
                $.each(jQuery('#applyRecordListGrid').jqGrid('getCol', 'applyId', false), function (k, v) {
                    var ret = jQuery("#applyRecordListGrid").jqGrid('getRowData', v);
                    if (k == 0) {
                        $("#applyRecordListGrid").setSelection(ret.applyId, true)
                    }
                });
            }
        }).trigger('reloadGrid');//重新载入


    }
</script>
</body>
</html>
